<?php
namespace Api\Controller;
use Think\Controller;
class PostController extends Controller {
   public function getAllPost(){
        $post=M('post');
        $data=$post->order("uid")->select();
        echo json_encode($data);  
    }
    public function getPostById(){
        $pid=$_GET['postid'];
        $post=M('post');
        $data=$post->where("postid='$pid'")->select();
        echo json_encode($data);
    }
   public function delPost(){
    $oid=$_GET['postid'];
    $orderModel=M('post');
    if($orderModel->delete($oid)){
        echo json_encode('1');
    }else{
        echo json_encode('0');
    }
   }

   public function update($pid){
    $up=M('post');
    $one=$up->where("postid=$pid")->find();
    $this->one=$one;
    $this->display();
   }
   public function updatePost(){
    $up=M('post');
    if($up->create()){
        if ($up->save()) {
            $this->success('修改成功','morePost');
        }else{
            $this->error('修改失败');
        }
    }
   }
}